<%-- 
    Document   : admoProductos
    Created on : 18/04/2013, 02:01:12 AM
    Author     : BlattaBlacs
--%>

<%@page contentType="text/html" pageEncoding="windows-1252"%>
<%--@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"--%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>PRODUCTOS</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style>
            body{
                background-color: #B8ABAF;
            }
            
        </style>
        <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css">
        <script src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxForm/codebase/dhtmlxcommon.js"></script>
        <script src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxForm/codebase/dhtmlxform.js"></script>
       
        <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxWindows/codebase/dhtmlxwindows.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxWindows/codebase/skins/dhtmlxwindows_dhx_black.css">
<script src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxWindows/codebase/dhtmlxcommon.js"></script>
<script src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxWindows/codebase/dhtmlxwindows.js"></script>
<script src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxWindows/codebase/dhtmlxcontainer.js"></script>
        
        <link rel="STYLESHEET" type="text/css" href="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.css">
        <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_black.css">
        <script  src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid//codebase/ext/dhtmlxgrid_rowspan.js"></script>
        <script  src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
        <script  src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
        <script  src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid/codebase/ext/dhtmlxgrid_filter.js"></script>
        <script  src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script> 
        <script  src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid/codebase/ext/dhtmlxgrid_validation.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxDataStore/codebase/datastore.js"></script>
    
       <!--<script src="${pageContext.request.contextPath}/resources/bootstrap/js/jquery-latest.js"></script>
        <script src="${pageContext.request.contextPath}/resources/bootstrap/js/bootstrap.min.js"></script>
       <link href="${pageContext.request.contextPath}/resources/shadowbox/shadowbox.css" rel="stylesheet" type="text/css"/>
        <script src="${pageContext.request.contextPath}/resources/shadowbox/shadowbox.js" type="text/javascript"/>
        <script type="text/javascript">
            Shadowbox.init({
                overlayColor: "#000",
                overlayOpacity: "0.6"
            });
        </script>
        <script type="text/javascript"><!--
            Shadowbox.init({
                handleOversize:     "drag",
                displayNav:         false,
                handleUnsupported:  "remove",
                autoplayMovies:     false
            });
            </script>

        <style type="text/css">
            #modal-background {
                display: none;
                position: fixed;
                top: 0;
                left: 0;
                width: 336;
                height: 99.6%;
                background-color: white;
                opacity: .50;
                -webkit-opacity: .5;
                -moz-opacity: .5;
                filter: alpha(opacity=50);
                z-index: 1000;
            }

            #modal-content {
                background-color: white;
                border-radius: 10px;
                -webkit-border-radius: 10px;
                -moz-border-radius: 10px;
                box-shadow: 0 0 20px 0 #222;
                -webkit-box-shadow: 0 0 20px 0 #222;
                -moz-box-shadow: 0 0 20px 0 #222;
                display: none;
                height: 336;
                left: 50%;
                margin: -120px 0 0 -160px;
                padding: 10px;
                position: absolute;
                top: 50%;
                width: 99.6%;
                z-index: 1000;
            }

            #modal-background.active, #modal-content.active {
                display: block;
            }
        </style> -->
        
    </head>
    <body>
        <!--<div class="span4">
            <div id="shadowboxModal" >
                <a id="boton" rel="shadowbox[ejemplos];options={continuous:true};width=800;height=540" href="http://localhost:8084/TiendaVirtual/administrador/insertaProducto">imagen a mostrar ShadowBox</a>
            </div>
        </div>-->
        <!--<div id="winVP" style="position: relative; height: 500px; border: #cecece 1px solid; margin: 10px;">-->
        <table>
            <tr><th><h3 style="font-family: Tahoma; margin-left: 344px;">PRODUCTOS</h3></th></tr>
            <tr>
                <td>
                  <div id="gridbox" style="width:600px; height:270px; margin-left: 370px;"></div>
                </td>
            </tr>
        </table>
       <!--  <input type="button" name="b1" value="add row" onClick="mygrid.addRow((new Date()).valueOf(),[1,2,'perro',4,5],1)"> -->
       

       
       <div style="width:600px; height:270px; margin-left: 560px; margin-top: 15px;">
           <button value="Insertar" onClick="doOnLoad()">Insertar</button>
          <!-- <button value="Insertar" onClick="inserta()">Insertar</button>-->
        <button value="Actualizar" onClick="actualiza()">Modificar</button>
        <button value="Borrar" onClick="elimina()">Borrar</button> 
       </div></div>
        <br />
     
        
        <script>
            var idGlobalDeLaFila=0;
            var idProducto='';
            var nombre='';
            var detalles='';
            var precio='';
           
            function elimina(){
                if(confirm('Esta seguro en eliminar la fila?')){
                dhtmlxAjax.post("../administrador/delete","clave="+idGlobalDeLaFila,function(loader){
                   // alert("Fila elminada de la BD exitosamente!!!");
                    location.reload();
                });
                }
            } 
     
            /*function inserta(){
                dhtmlxAjax.post("../administrador/insertpro","claveProducto=0101A101T01&nombre=NombreProducto&detalles=DetallesProducto&precio=100&",function(loader){
                    alert("inserto!!");
                    location.reload();
                });
            } */
     
            function actualiza(){
           
                 //var pagina="../administrador/insertaProducto";
               // location.href=pagina;
                /*dhtmlxAjax.post("../administrador/update","clave="+idGlobalDeLaFila+"&claveProducto="+idProducto+"&nombre="+nombre+"&detalles="+detalles+"&precio="+precio,function(loader){
                    alert("actualizo!!");
                    location.reload();
                });*/
            } 
             var data = new dhtmlXDataStore({
                url: "../administrador/mostrar",
                datatype: "json"
            });
            
            mygrid = new dhtmlXGridObject({
                parent:"gridbox",
                onRowSelect:function(){
			//alert("I'm clicked");	
		}
            });
            
            function doOnRowSelect(id) {
                var idFile= mygrid.getSelectedId();
                var d= mygrid.cells(idFile,0).getValue();
                idGlobalDeLaFila=d;
                idProducto=mygrid.cells(idFile,1).getValue();
                nombre=mygrid.cells(idFile,2).getValue();
                detalles=mygrid.cells(idFile,3).getValue();
                precio=mygrid.cells(idFile,4).getValue();
                //alert(t);
            }
            mygrid.setImagePath("${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxGrid/codebase/imgs/");
            mygrid.setSkin("dhx_black");  
            mygrid.setHeader("Clave,Clave Producto,Nombre,Detalles,Precio");
            mygrid.setColAlign("left,center,center,right");
            mygrid.setColTypes("ed,ed,ed,ed,price"); //ro
            mygrid.setColSorting("int,str,str,str,int");
            mygrid.attachEvent("onRowSelect", doOnRowSelect);
            mygrid.setColumnIds("clave,claveProducto,nombre,detalles,precio");
           // mygrid.setColValidators([null,"NotEmpty","NotEmpty","NotEmpty","ValidNumeric"]);
            //mygrid.enableAutoHeight(true)
            //mygrid.enableValidation(true, true, true, true,true);
            //mygrid.setColValidators([null,null,"Max15","Max35","Max10"]);
           
            mygrid.init();
            mygrid.sync(data, {
                sort: true,
                filter: true
            });
            
var dhxWins,w1;

function doOnLoad() {
    dhxWins = new dhtmlXWindows();
    dhxWins.enableAutoViewport(true);
    //dhxWins.attachViewportTo("winVP");
    dhxWins.setImagePath("../../../dhtmlxWindows/codebase/imgs/");
    dhxWins.setSkin("dhx_black");
   w1 = dhxWins.createWindow("w1", 550, 50, 315, 370);
      w1.setText("Inserta Tu Producto");
      w1.button("minmax1").hide();
      w1.denyResize();
      w1.setModal(true);
    w1.attachURL("http://localhost:8084/TiendaVirtual/administrador/insertaProducto", true);
}
        </script>
    </body>
</html>